// 二维差分模版(牛客)
// 测试链接 : https://www.nowcoder.com/practice/50e1a93989df42efb0b1dec386fb4ccc
// 提交以下的全部代码，可以直接通过

#include <cstdio>

const int MAXN = 1005;
const int MAXM = 1005;

long diff[MAXN][MAXM];
int n, m, q;

void add(int a, int b, int c, int d, int k)
{
    diff[a][b] += k;
    diff[c + 1][b] -= k;
    diff[a][d + 1] -= k;
    diff[c + 1][d + 1] += k;
}   

void build()
{
    for(int i = 1; i <= n; ++i)
    {
        for(int j = 1; j <= m; ++j)
        {
            diff[i][j] += diff[i][j - 1] + diff[i - 1][j] - diff[i - 1][j - 1];
        }
    }
}

int main()
{
    scanf("%d%d%d", &n, &m, &q);
    int k;
    for(int i = 1; i <= n; ++i)
    {
        for(int j = 1; j <= m; ++j)
        {
            scanf("%d", &k);
            add(i, j, i, j, k);
        }
    }

    int a, b, c, d;
    for(int i = 0; i < q; ++i)
    {
        scanf("%d%d%d%d%d", &a, &b, &c, &d, &k);
        add(a, b, c, d, k);
    }

    build();
    for(int i = 1; i <= n; ++i)
    {
        printf("%ld", diff[i][1]);
        for(int j = 2; j <= m; ++j)
        {
            printf(" %ld", diff[i][j]);
        }
        printf("\n");
    }

    return 0;
}